package com.hellobike.haxing.modules.shop.job;

import com.hellobike.haxing.common.constant.CacheConstant;
import com.hellobike.haxing.common.util.RedisUtil;
import com.hellobike.haxing.modules.shop.service.IShopWithdrewMonthCountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 删除小于但前月的门店月提现金额
 */
@Slf4j
@Component
public class MonthDeleteAmountJob {

    @Autowired
    private IShopWithdrewMonthCountService shopWithdrewMonthCountService;
    @Autowired
    private RedisUtil redisUtil;
    /**
     * 每月1号的00:01:00执行
     */
    @Scheduled(cron = "0 01 0 1 * ?")
    public void execute(){
        Object result = redisUtil.get(CacheConstant.WITHDREW_MONTH_CLEAR_JOB);
        if(result!=null){return;}
        redisUtil.set(CacheConstant.WITHDREW_MONTH_CLEAR_JOB,1,600);
        shopWithdrewMonthCountService.deleteMonthCount();
    }
}
